<?php
$dbhost = "localhost";
$dbuser = "echoblog";
$dbpass = "echoblog";
$dbname = "echoblog";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

// 博客管理密码
$pw = "password";
// 博客管理用户名
$un = "admin";
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}


// 定义核心库目录路径
$core = './function';
// 定义控制器目录路径、
$controller = './controller';

// 使用 glob 获取目录下所有 .php 文件
$phpFiles = glob($core . '/*.php');

$classNames = [];
$classList = [];
// 遍历并引用每个文件
foreach ($phpFiles as $file) {
    if (file_exists($file)) {
        include $file;
        // 类名等于文件名（不包含后缀）
        $className = pathinfo($file, PATHINFO_FILENAME);
        $classNames[] = $className;
        // 实例化一个与名字相同类实例
        $instance = new $className();
        $classList[$className] = $instance;
    }
}
$phpFiles = glob($controller . '/*.php');

// 遍历并引用每个文件
foreach ($phpFiles as $file) {
    if (file_exists($file)) {
        include $file;
        // 类名等于文件名（不包含后缀）
        $className = pathinfo($file, PATHINFO_FILENAME);
        $classNames[] = $className;
        // 实例化一个与名字相同类实例
        $instance = new $className();
        $classList[$className] = $instance;
    }
}
?>
